/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package PasswrdChk02.Regras;
import InterfacesPasswordChecker02.BonusFactory;
import PasswrdChk02.Componentes.Somatorios;


/**
 *
 * @author LABCCET
 */
public class Bonus implements BonusFactory{
    String password;
    Somatorios somatorios;

    public Bonus(String password) {
        this.password = password;
        this.somatorios = new Somatorios(password);
    }
    
    
    private final int FATOR_BONUS_SIMBOLOS = 6;
    private final int FATOR_BONUS_DIGITOS = 4;
    private final int FATOR_BONUS_REQUERIMENTOS = 2;
    private final int FATOR_BONUS_LITERAIS = 2; // Para Letras Maiusculas e Minusculas
    private final int FATOR_BONUS_NAO_LITERAIS_INTERMEDIARIOS = 2;
    
    @Override
    public int calcularBonusMaiusculas(){
        int total = somatorios.somarMaiusculas();
        return (total<password.length() && total>0)?(password.length() - total)* FATOR_BONUS_LITERAIS:0;
    }      
    
    @Override
    public int calcularBonusMinusculas(){
        int total = somatorios.somarMinusculas();
        return (total<password.length() && total>0)?(password.length() - total)* FATOR_BONUS_LITERAIS:0;
    }
        
    @Override
    public int calcularBonusDigitos(){
        int total = somatorios.somarDigitos();
        return (total<password.length() && total>0)? total* FATOR_BONUS_DIGITOS:0;
    }
    
    @Override
    public int calcularBonusSimbolos(){
        int total = somatorios.somarSimbolos();
        return (total<=password.length() && total>0)? total* FATOR_BONUS_SIMBOLOS:0;
    }
    
    @Override
    public int calcularBonusNaoLiteraisIntermediarios(){
        return somatorios.somarNaoLiteraisIntermediarios()* FATOR_BONUS_NAO_LITERAIS_INTERMEDIARIOS;
    } 
   
    @Override
    public int calcularBonusRequerimentos(){
        Requerimentos requerimentos = new Requerimentos(password);
        int qtdeRequerimentos = requerimentos.qtdeDeRequerimentosSenha();
        return requerimentos.isElegibleForRequerimentsBonus()? (qtdeRequerimentos* FATOR_BONUS_REQUERIMENTOS):0 ;
    } 
     
    @Override
    public int calcularBonus() {
        return this.calcularBonusDigitos()+this.calcularBonusMaiusculas()+
                this.calcularBonusMinusculas()+this.calcularBonusNaoLiteraisIntermediarios()+
                this.calcularBonusRequerimentos()+this.calcularBonusSimbolos();
    }

   
}
